home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Telnet 2.6.1d1 4⁄26⁄94 Folder / source / debug.c next >
Text File  |  1994-04-16  |  3KB  |  113 lines

  1. /****************************************************************
  2. *    NCSA Telnet for the Macintosh                                *
  3. *                                                                *
  4. *    National Center for Supercomputing Applications                *
  5. *    Software Development Group                                    *
  6. *    152 Computing Applications Building                            *
  7. *    605 E. Springfield Ave.                                        *
  8. *    Champaign, IL  61820                                        *
  9. *                                                                *
  10. *    Copyright (c) 1986-1992,                                    *
  11. *    Board of Trustees of the University of Illinois                *
  12. ****************************************************************/
  13.  
  14. #ifdef MPW
  15. #pragma segment 7
  16. #endif
  17.  
  18. #include <string.h>
  19.  
  20. #include "TelnetHeader.h"
  21. #include "vsdata.h"
  22. #include "vsinterf.proto.h"                    /* For VSwrite proto */
  23. #include "wind.h"                        /* For WindRec structure */
  24. #include "debug.h"
  25. #include "parse.proto.h"        // For DemangleLinemodeShort
  26. #include "rsmac.proto.h"        // For RSshow proto
  27.  
  28. WindRec    *console;        /*    Window Record (VS) for :    console Window   */
  29. extern WindRec    *screens;
  30.  
  31. //#define DEBUG_FACILITIES
  32.  
  33. #ifdef SUPPORT_AUDIT
  34. #include "Audit.h"
  35. AuditPtr    gAuditPtr = NULL;
  36. #endif
  37.  
  38. void InitDebug(void)
  39. {
  40. #ifdef DEBUG_FACILITIES
  41. #ifdef SUPPORT_AUDIT
  42.     gAuditPtr = GetAuditPtr('NCSA');
  43. #endif
  44.     Rect pRect;
  45.  
  46.     console = (WindRec *) NewPtrClear(sizeof(WindRec));
  47.     
  48.     SetRect(&pRect, 50, 150, 700, 350);        // Need to make this a resource!
  49.     
  50.     console->vs=RSnewwindow( &pRect, 350, 80, 24,
  51.                     "\p<console>", 1, DefFONT, DefSIZE, TelInfo->debug,0,0);    /* NCSA 2.5 */
  52.  
  53.     console->wind = RSgetwindow( console->vs);
  54.     ((WindowPeek)console->wind)->windowKind = WIN_CONSOLE;
  55.  
  56.     VSwrite(console->vs,"\033[24;0H",1);        
  57.     console->active=0;
  58.     console->port=0;
  59.     console->termstate=VTEKTYPE;
  60.     console->national = 0;            /* LU: no translation */
  61. #else
  62.     console = NULL;
  63. #endif
  64. }
  65.  
  66. void putln( char *cp)                                
  67. {
  68. #ifdef DEBUG_FACILITIES
  69.     short temp;
  70.     Str255    temppstr;
  71.     
  72.     strcpy((char *)temppstr, cp);
  73.     CtoPstr((char *)temppstr);
  74.     
  75. #ifdef SUPPORT_AUDIT
  76.     AuditString(gAuditPtr, 'PTLN', temppstr);
  77. #endif
  78.     
  79.     if (!TelInfo->debug)
  80.         return;
  81.  
  82.     temp=strlen(cp);
  83.     if (temp>80) return;
  84.     VSwrite(console->vs,cp,temp);
  85.     VSwrite(console->vs,"\015\012",2);
  86. #endif
  87. }
  88.  
  89. // Called by HandleKeyDown.  Allows me to insert debug info keys all in one place
  90. //    that can be easily #defined out for release versions.  Returns TRUE if
  91. //    HandleKeyDown should do an immediate return after calling us.
  92. Boolean    DebugKeys(Boolean cmddwn, unsigned char ascii, short s)
  93. {
  94. #ifdef DEBUG_FACILITIES
  95.     if (cmddwn && (ascii == ';')) {    // 2.6b16.1
  96.         char hackhackhack[80];
  97.         
  98.         strcpy(hackhackhack, "Linemode: ");
  99.         DemangleLineModeShort(hackhackhack, screens[s].lmode);
  100.         putln(hackhackhack);
  101.         return(FALSE);
  102.         }
  103. #endif
  104.     return (FALSE);
  105. }
  106.  
  107. void    ShowDebugWindow(void)
  108. {
  109. #ifdef DEBUG_FACILITIES
  110.     if (console != NULL)
  111.         RSshow(console->vs);
  112. #endif
  113. }